package Test;

import java.util.concurrent.*;

public class Test7 {

    public static void main(String[] args) {
       ExecutorService pool = Executors.newSingleThreadExecutor();
        //循环十次,每次都用线程池调用这个任务
        for (int i = 0; i < 10; i++) {
            int count = i;
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() +"----"+ count);

                }
            });
        }
    }
}
